package com.youxuit.youxu.kecheng.threadLocal.usage1;

import java.text.SimpleDateFormat;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


public class DateFormatUsage06 {
    static ExecutorService executorService = Executors.newFixedThreadPool(10);

    public static void main(String[] args) {
        for (int i = 0; i < 1000; i++) {
            int finalI = i;
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    SimpleDateFormat simpleDateFormat = SimpleDataFormat.threadLocal.get();
                    System.out.println(simpleDateFormat.format(finalI * 1000));
                }
            });
            executorService.shutdown();
        }
    }

}

class SimpleDataFormat {
    static ThreadLocal<SimpleDateFormat> threadLocal = new ThreadLocal<SimpleDateFormat>() {
        @Override
        protected SimpleDateFormat initialValue() {
            return new SimpleDateFormat("yyyy-MM-dd hh:ss:mm");
        }
    };
}
